package com.jackrain.nea.fc.dl.mapper;


import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import java.util.HashMap;
import java.util.List;

/**
 * 出入库通知
 * Mapper
 * @author xuxinshuai
 * @create 2018/05/12
 */
@Mapper
public interface WmsDLTranMapper {


    //发出
    @Select("SELECT BILL_NO AS bill_no ," +
            "case when TRAN_FLAG = '1' then 'DI' else 'TR' end as bill_type, " +
            "BIGINT4 as bigint4," +
            "BILL_DATE AS bill_date ," +
            "NULL AS order_type," +
            "CP_C_ORIG_ECODE  AS orig_ecode ," +
            "CP_C_DEST_ECODE AS dest_ecode," +
            "CP_C_DEST_ID AS wms_store_code," +
            "REMARK AS remark , " +
            "'80' AS recive_status ," +
            "NOW() as write_time ," +
            "NULL AS recive_time," +
            "NULL AS recive_err_msg , " +
            "OWNERENAME AS owner_ename," +
            "OWNERNAME AS owner_name," +
            "CREATIONDATE AS creation_date," +
            "MODIFIERENAME AS modifier_ename ," +
            "MODIFIERNAME AS modifier_name ," +
            "MODIFIEDDATE AS modified_date , " +
            "NULL AS userdefine1 ," +
            "NULL AS userdefine2 ," +
            "NULL AS userdefine3, " +
            "NULL AS userdefine4," +
            "NULL AS userdefine5 " +
            "FROM  DL_B_TRAN a " +
            "WHERE MODIFY_BILL_NO IS NULL " +
            "AND TRAN_B_BILL_BOX_NO IS NULL " +
            "AND SEND_STATUS=2  " +
            "AND ID IN ( #{ids} )")
    HashMap selectwmstraninsql(String ids);

    @Select("SELECT BILL_NO AS bill_no ," +
            "case when TRAN_FLAG = '1' then 'DI' else 'TR' end as bill_type, " +
            "BIGINT4 as bigint4," +
            "BILL_DATE AS bill_date ," +
            "NULL AS order_type," +
            "CP_C_ORIG_ECODE  AS orig_ecode ," +
            "CP_C_DEST_ECODE AS dest_ecode," +
            "CP_C_DEST_ID AS wms_store_code," +
            "REMARK AS remark , " +
            "'80' AS recive_status ," +
            "NOW() as write_time ," +
            "NULL AS recive_time," +
            "NULL AS recive_err_msg , " +
            "OWNERENAME AS owner_ename," +
            "OWNERNAME AS owner_name," +
            "CREATIONDATE AS creation_date," +
            "MODIFIERENAME AS modifier_ename ," +
            "MODIFIERNAME AS modifier_name ," +
            "MODIFIEDDATE AS modified_date , " +
            "NULL AS userdefine1 ," +
            "NULL AS userdefine2 ," +
            "NULL AS userdefine3, " +
            "NULL AS userdefine4," +
            "NULL AS userdefine5 " +
            "FROM  DL_B_TRAN a " +
            "WHERE IS_PICK='Y' " +
            "AND SEND_STATUS=2 " +
            "AND ISACTIVE='Y' " +
            "AND ID = #{ids} ")
    HashMap selectTranBoxById(String ids);


    @Select("SELECT PS_C_SKU_ECODE AS sku," +
            "QTY_BILL AS qty_bill," +
            "OWNERENAME AS owner_ename," +
            "OWNERNAME AS owner_name," +
            "CREATIONDATE AS creation_date," +
            "MODIFIERENAME AS modifier_ename ," +
            "MODIFIERNAME AS modifier_name ," +
            "MODIFIEDDATE AS modified_date , " +
            "NULL AS userdefine1 ," +
            "NULL AS userdefine2 ," +
            "NULL AS userdefine3, " +
            "NULL AS userdefine4," +
            "NULL AS userdefine5 " +
            "FROM  DL_B_TRAN_ITEM_SKU a " +
            "WHERE DL_B_TRAN_ID IN ( #{ids} )")
    List<HashMap> selectwmstranintimesql(String ids);


    //提交
    @Select("SELECT BILL_NO AS bill_no ," +
            "case when TRAN_FLAG = '1' then 'DI' else 'TO' end as bill_type, " +
            "BILL_DATE AS bill_date ," +
            "BIGINT4 as bigint4," +
            "STATUS AS STATUS ," +
//            "ACCEPTE_STATUS AS SEND_STATUS ," +

//            "CP_C_STORE_ID AS wms_store_code," +
            "CP_C_ORIG_ECODE  AS orig_ecode , " +
            "CP_C_DEST_ECODE AS dest_ecode," +
//            "CP_C_STORE_ID AS logistics_batch," +
            "REMARK AS remark , " +
            "'80' AS recive_status ," +
            "NOW() as write_time ," +
            "NULL AS recive_time," +
            "NULL AS recive_err_msg , " +
            "OWNERENAME AS owner_ename," +
            "OWNERNAME AS owner_name," +
            "CREATIONDATE AS creation_date," +
            "MODIFIERENAME AS modifier_ename ," +
            "MODIFIERNAME AS modifier_name ," +
            "MODIFIEDDATE AS modified_date , " +
            "NULL AS userdefine1 ," +
            "NULL AS userdefine2 ," +
            "NULL AS userdefine3, " +
            "NULL AS userdefine4," +
            "NULL AS userdefine5 " +
            "FROM  DL_B_TRAN a " +
            "WHERE MODIFY_BILL_NO  IS NULL " +
            "AND ID IN ( #{ids} )")
    HashMap selectwmstranoutsql(String ids);

    @Select("SELECT PS_C_SKU_ECODE AS sku," +
            "QTY_BILL AS qty_bill," +
            "OWNERENAME AS owner_ename," +
            "OWNERNAME AS owner_name," +
            "CREATIONDATE AS creation_date," +
            "MODIFIERENAME AS modifier_ename ," +
            "MODIFIERNAME AS modifier_name ," +
            "MODIFIEDDATE AS modified_date , " +
            "NULL AS userdefine1 ," +
            "NULL AS userdefine2 ," +
            "NULL AS userdefine3, " +
            "NULL AS userdefine4," +
            "NULL AS userdefine5 " +
            "FROM  DL_B_TRAN_ITEM_SKU a " +
            "WHERE  DL_B_TRAN_ID IN ( #{ids} )")
    List<HashMap> selectwmstranouttimesql(String ids);

    //取消提交

    @Select(" SELECT BILL_NO AS bill_no " +
            " FROM  DL_B_TRAN  " +
            " WHERE ID IN ( #{ids} )")
    HashMap selectwmstranoutbillnosql(String ids);



    @Select("SELECT " +
            "ID, " +
            "BILL_NO, " +
            "BILL_DATE, " +
            "CP_C_ORIG_ECODE AS ORIG_ECODE, " +
            "CP_C_DEST_ECODE AS DEST_ECODE, " +
            "REMARK, " +
            "OWNERENAME AS OWNER_ENAME, " +
            "OWNERNAME AS OWNER_NAME, " +
            "CREATIONDATE AS CREATION_DATE, " +
            "MODIFIERENAME AS MODIFIER_ENAME, " +
            "MODIFIERNAME AS MODIFIER_NAME, " +
            "MODIFIEDDATE AS MODIFIED_DATE,  " +
            "MODIFY_BILL_NO," +
            "WMS_OUT, " +
            "WMS_IN "+
            "FROM DL_B_TRAN  " +
            "WHERE MODIFY_BILL_NO IS NOT NULL AND  ID IN (#{ids})")
    HashMap selectwmstranout1(String ids);

    @Select("SELECT  " +
            "PS_C_SKU_ECODE AS SKU,  " +
            "QTY_BILL,  " +
            "OWNERENAME AS OWNER_ENAME,  " +
            "OWNERNAME AS OWNER_NAME,  " +
            "CREATIONDATE AS CREATION_DATE,  " +
            "MODIFIERENAME AS MODIFIER_ENAME,  " +
            "MODIFIERNAME AS MODIFIER_NAME,  " +
            "MODIFIEDDATE AS MODIFIED_DATE  " +
            "FROM DL_B_TRAN_ITEM_SKU  " +
            "WHERE DL_B_TRAN_ID IN ( #{ids} )")
    List<HashMap> selectwmstranoutitem1(String ids);


}